<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:insert="~{include :: header('新增需求分类')}" />
	<th:block th:insert="~{include :: select2-css}" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-categorie-add">
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">名称：</label>
                    <div class="col-sm-6">
                        <input name="name" class="form-control" type="text" required>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:insert="~{include :: footer}" />
	<th:block th:insert="~{include :: select2-js}" />
    <script th:inline="javascript">
        var prefix = ctx + "system/categorie"
        $("#form-categorie-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.modal.loading("正在保存中...");
                $.post(prefix + "/add", $('#form-categorie-add').serialize(), function(result) {
                    $.modal.closeLoading();
                    if (result.code == web_status.SUCCESS) {
                        console.log(window.parent.refreshCategoryDropdown);
                        // 通知父窗口刷新类别下拉框
                        if (window.parent.refreshCategoryDropdown) {
                            window.parent.refreshCategoryDropdown();
                        }
                        $.modal.msgSuccess(result.msg);
                        $.modal.close();
                    } else {
                        $.modal.alertError(result.msg);
                    }
                });
            }
        }
    </script>
</body>
</html>